package com.two.screen.water.balance.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

public class FocusLinearlayout extends LinearLayout {
   public FocusLinearlayout(Context context) {
      super(context);
   }

   public FocusLinearlayout(Context context, @Nullable AttributeSet attrs) {
      super(context, attrs);
   }

   public FocusLinearlayout(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
   }

   public FocusLinearlayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
      super(context, attrs, defStyleAttr, defStyleRes);
   }

   @Override
   public View focusSearch(View focused, int direction) {
      if(focused instanceof EditText){
         EditText editText = ((EditText) focused);
         //光标移入文件末尾
         editText.setSelection(editText.getText().length());
      }
      return super.focusSearch(focused,direction);
   }
}
